package time;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TestSimpleDateFormat {
    public static void main(String[] args) throws ParseException {

        Date d = new Date();
        System.out.println(d);

        long time = d.getTime();
        System.out.println(time);


        // 1 格式化日期
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd  HH:mm:ss  EEE a");
        String rs = sdf.format(d);
        System.out.println(rs);

        String rs2 = sdf.format(time);
        System.out.println(rs2);


        // 2 将字符串形式转换为系统时间
        String dateStr = "2022-12-12  12:12:12";
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd  HH:mm:ss");
        Date d2 = sdf2.parse(dateStr);
        System.out.println(d2);

    }
}
